home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
jovept2.arc
/
TAG.C
< prev
next >
Wrap
Text File
|
1985-05-30
|
2KB
|
117 lines
/* tag.c */
/* JOVE/MSDOS. K. Mitchum 1/85 */
/* Modifications for personal use only. */
/* original code J. Payne LSRHS 5/83 */
/* Ken Mitchum */
/* University of Pittsburgh */
/* Decision Systems Laboratory */
/*
Jonathan Payne at Lincoln-Sudbury Regional High School 5-25-83
C tags package. */
#include "jove.h"
extern char searchbuf[];
/* Find the line with the correct tagname at the beginning of the line.
* then put the data into the struct, and then return a pointer to
* the struct. 0 if an error.
*/
look_up(sstr, filebuf, name)
register char *name;
char *sstr,
*filebuf;
{
register int namlen = strlen(name);
char line[LBSIZE];
register char *cp;
if ((io = open("tags", 0)) == -1) {
message(IOerr("open", "tags"));
return 0;
}
while (getfline(line) != EOF) {
if (line[0] != *name || strncmp(name, line, namlen) != 0)
continue;
if (line[namlen] != '\t')
continue;
else {
char *endp,
*newp;
if (cp = index(line, '\t'))
cp++;
else
tagerr: complain("Bad tag file format");
if (endp = index(cp, '\t'))
*endp = 0;
else
goto tagerr;
strcpy(filebuf, cp);
if ((newp = index(endp + 1, '/')) ||
(newp = index(endp + 1, '?')))
newp++;
else
goto tagerr;
strcpy(sstr, newp);
sstr[strlen(sstr) - 1] = 0;
IOclose();
return 1;
}
}
IOclose();
return 0;
}
TagError(tag)
char *tag;
{
s_mess("tag: %s not found", tag);
}
/*
* Find_tag searches for the 'tagname' in the file "tags".
* The "tags" file is in the format generated by "/usr/bin/ctags".
*/
find_tag(tagname)
char *tagname;
{
char filebuf[50],
sstr[100];
BUFLOC *bp;
if (look_up(sstr, filebuf, tagname) == 0) {
TagError(tagname);
return;
}
SetBuf(do_find(curwind, filebuf));
Bof();
if ((bp = dosearch(sprint(sstr, tagname), 1, 1)) == 0)
TagError(tagname);
else
SetDot(bp);
}
/* Called from user typing ^X t */
FindTag()
{
char *tagname;
tagname = ask((char *) 0, FuncName());
find_tag(tagname);
}
/*-------------------------o.s. dependent-----------------------*/
/* end */